package org.simpleframework.mvc.type;

import lombok.Getter;

import java.util.HashMap;
import java.util.Map;

/**
 * 存储处理完后的结果数据,以及显示该数据的视图
 *
 * @author: Oliver
 * @time: 2021/1/1/11:13
 */
@Getter
public class ModelAndView {
    private String view;
    private Map<String, Object> data = new HashMap<>();

    public ModelAndView setView(String view) {
        this.view = view;
        return this;
    }

    /**
     * modelAndView.setView("addheadline.jsp").addViewData("aaa", "bbb");
     *
     * @return
     */
    public ModelAndView addViewData(String attrName, Object data) {
        this.data.put(attrName, data);
        return this;
    }
}
